class Solution {
public:
    vector<int> canSeePersonsCount(vector<int>& heights)
	{
    	int n = heights.size();
		vector<int> sum(n,0);
		stack<int> Mtall;
		for(int i=n-1;i>=0;i--)
		{
			while(!Mtall.empty() && Mtall.top()<heights[i])
			{
					Mtall.pop();
					sum[i]++;
			}
			if(!Mtall.empty())
			{
				sum[i]++;
			}
			Mtall.push(heights[i]);		
		} 	   

		return sum;
	}
};

